home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Unix / prettyprinter.perl < prev    next >
Text File  |  1993-05-21  |  9KB  |  179 lines

  1. #Newsgroups: comp.archives.admin,comp.sys.mac.misc
  2. #Subject: Pretty-printer for mac.archive.umich.edu listings
  3. #From: jonathan@cs.pitt.edu (Jonathan Eunice)
  4. #Date: 31 Jan 93 17:46:19 GMT
  5. #Followup-To: comp.archives.admin
  6. #Distribution: na
  7. #Organization: University of Pittsburgh Computer Science
  8. #
  9. #
  10. #The following is a perl script that beautifies the listings
  11. #periodically published in comp.archvies of new files at
  12. #mac.archive.umich.edu.  These listings are very helpful, but printed in
  13. #an ugly and hard-to-use format, IMHO.  This program fixes all that.
  14. #Requires perl (of course) and a wide screen or window (output is ~120
  15. #cols).
  16. #
  17. #
  18. #
  19. #
  20. #--------------- CUT HERE ------------------
  21. #!/usr/local/bin/perl
  22.  
  23. # mac-listing
  24. #
  25. # Perl script to pretty-print mac.archive.umich.edu listings
  26. # of Mac files.  Output is ~120 columns--REQUIRES wide screen
  27. # or window to be of any use whatever.
  28.  
  29. # To use:  Save archive announcements to a file,
  30. # say 'macfiles'.  Trim mail headers/trailers.  Then run 
  31. # 'mac-listing macfiles'.  Sample output follows:
  32.  
  33. # File                          Path                                Comment
  34. # ---------------------------------------------------------------------------------------------------------------------
  35. # epsfibmpctomac1.01.sit.hqx    /mac/graphics/graphicsutil/         Translators to convert between different types of
  36. #                                                                   EPSF (encapsulated PostScript) files.  For use with
  37. #                                                                   Apple File Exchange.
  38. # macghostscript2.52.cpt.hqx    /mac/graphics/graphicsutil/         A port of the Free Software Foundation's
  39. #                                                                   Ghostscript -- a general- purpose PostScript
  40. #                                                                   interpreter.  Includes fonts.  Minimal interface.
  41. #                                                                   Requires Color QuickDraw.
  42. # randomdotstereograms2.4.sit.h /mac/graphics/graphicsutil/         Software to view Random Dot Autostereograms (RDAs),
  43. #                            qx                                     images that contain three dimensional information
  44. #                                                                   in a single image instead of a pair of images
  45. #                                                                   typically refered to as a stereo pair.  Several
  46. #                                                                   images provides, and can also generate the same
  47. #                                                                   images as provided. Slow, slow, slow, slow, slow
  48. #                                                                   (but there isn't much else out there). Includes
  49. #                                                                   versions for Macs with and without math
  50. #                                                                   coprocessors.
  51. # dithercomparison.sit.hqx      /mac/hypercard/organization/        Demonstrate the difference in quality between
  52. #                                                                   standard Color QuickDraw dithering and QuickTime's
  53. #                                                                   "fast dithering." Requires QuickTime and HyperCard
  54. #                                                                   2.0.
  55. # garton.cpt.hqx                /mac/system.extensions/font/type1/  Size:  18, 24, 36, 48 A semi-script serif display
  56. #                                                                   font with a full set of  characters, numbers,
  57. #                                                                   punctuation, a few ligatures, and a helping of
  58. #                                                                   upper- and lower-case swash characters. Nice.
  59. #                                                                   Includes TrueType.
  60.  
  61.  
  62.  
  63. # This program is in the public domain.  Do with it what you will.
  64. # Written by Jonathan Eunice (jonathan@cs.pitt.edu), who finds it
  65. # useful and hopes you will too.  If you don't, too bad!
  66. # Author makes no warranties whatever.  Use at your own risk.
  67.  
  68.  
  69.  
  70. $= = 999999;    # infinite page length, only one output header
  71.         # change to 60 or so for one header per page
  72.  
  73. # scan input files
  74.  
  75. $first = 1;
  76. while (<>) {
  77.     chop;
  78.     if (m=^/=) {        # pathname -- starts new entry
  79.         if (!$first) {
  80.             $arr{$pathname} = $comment;
  81.         }
  82.         $pathname = $_;
  83.         $first = 0;
  84.         undef($comment);
  85.     }
  86.     elsif (/^\s*$/) {    # blank line
  87.         next;        # skip it
  88.     }
  89.     elsif (/^\s*\d+\s+\d+\/\d+\/\d+\s+[\w\d]+/) {    # Infoline
  90.         next;        # skip it
  91.     }
  92.     else {             # must be comments 
  93.         m/^\s*(\S.*)\s*$/;    # take only good stuff
  94.         $comment = "$comment $1"; # append to comment
  95.     }
  96.         
  97. }
  98.  
  99. # now sort and print
  100.  
  101. @keys = keys(%arr);
  102. @keys = sort(@keys);
  103. foreach $key (@keys) {
  104.     $key =~ m=^(/.+/)([\w\.]+)\s*$=;    # find line components
  105.     $path = $1;
  106.     $filename = $2;
  107.     $comment = $arr{$key};
  108.     $comment =~ s/^\s*//;
  109.     write;                # print line components
  110. }
  111.  
  112.  
  113. # Sample input lines follow. 
  114. # /mac/game/board/lineup2.01.cpt.hqx
  115. #   98     1/19/93    BinHex4.0,Compact1.33
  116. #  
  117. #    Connect Four.  You can play two player, or you vs. the computer, or
  118. #    the computer vs. itself. Various degrees of difficulty.  Includes
  119. #    option for play on a network.
  120. #  
  121. # /mac/misc/demo/rightontime1.5.cpt.hqx
  122. #  112     1/19/93    BinHex4.0,Compact1.33
  123. #  
  124. #    An application that provides To-Do List, Calendar, and Reminder
  125. #    features.  Demo version is limited to five records.
  126. #  
  127. # /mac/system.extensions/chooser/chucksdrivers1.00d.sit.hqx
  128. #   63     1/19/93    BinHex4.0,StuffIt1.5.1
  129. #  
  130. #    Printer drivers that work with Panasonic/Epson 9 and 24 pin
  131. #    printers and compatibles for both text and graphics.
  132.  
  133.  
  134.  
  135. # Output formats.
  136.  
  137. format STDOUT_TOP =
  138. File                          Path                                Comment
  139. ---------------------------------------------------------------------------------------------------------------------
  140. .
  141.  
  142. format STDOUT = 
  143. ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  144. $filename,                    $path,                              $comment
  145. ^>>>>>>>>>>>>>>>>>>>>>>>>>...~^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>... ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  146. $filename,                    $path,                              $comment
  147. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  148.                                                                   $comment
  149. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  150.                                                                   $comment
  151. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  152.                                                                   $comment
  153. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  154.                                                                   $comment
  155. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  156.                                                                   $comment
  157. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  158.                                                                   $comment
  159. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  160.                                                                   $comment
  161. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  162.                                                                   $comment
  163. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  164.                                                                   $comment
  165. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  166.                                                                   $comment
  167. ~                                                                 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
  168.                                                                   $comment
  169.  
  170. .
  171. # dont delete almost-invisible line above!!
  172.  
  173. # end of perl script 
  174.